package test.h0815;

import java.util.Scanner;

/**
  * @description 分割均衡字符串
  * @author 不知名帅哥
  * @date 2024/8/15 16:03
  * @version 1.0
*/
public class Main6 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s = sc.nextLine();
        //字符个数相同
        //给定的字符串均为均衡字符串

        //使用双指针
        int start=0;
        int end=0;

        int countX=0;
        int countY=0;
        int ans=0;
        while (start<s.length()&&end<s.length()){
            char c = s.charAt(end);
            if (countX!=0&&countY!=0&&countX==countY){
                ans++;
                //置为0
                countX=0;
                countY=0;
                continue;
            }else if (c=='X'){
                countX++;
            }else if (c=='Y'){
                countY++;
            }
            end++;
        }
        if (countX!=0&&countX==countY){
            ans++;
        }
        System.out.println(ans);
    }
}
